using UnityEngine;

public class KineticElementMoveConstant : KineticPlanElement
{
	public Vector3 desiredEndPosition;

	public float duration;

	protected Vector3 speed;

	public override float length
	{
		get
		{
			return duration;
		}
	}

	public new virtual float durationTillEnd
	{
		get
		{
			return length - base.ellapsedTime;
		}
	}

	public new virtual KineticPlan.TransformState GetEndState(KineticPlan.TransformState startState)
	{
		startState.position = desiredEndPosition;
		return startState;
	}

	public override void OnStart(Transform character)
	{
		base.OnStart(character);
		startPosition = character.position;
		startRotation = character.rotation;
		speed = (desiredEndPosition - startPosition) / duration;
		float num = Mathf.Sign(character.transform.position.z);
		base.animator.SetFloat("SpeedX", (0f - num) * speed.x);
		base.animator.SetFloat("SpeedY", (0f - num) * speed.z);
	}

	public override void OnAnimatorMove()
	{
		base.OnAnimatorMove();
		if (base.ellapsedTime >= duration)
		{
			OnLateUpdate();
			isActive = false;
		}
	}

	public override void OnLateUpdate()
	{
		if (isActive)
		{
			float num = Mathf.Sign(character.transform.position.z);
			base.animator.SetFloat("SpeedX", (0f - num) * speed.x);
			base.animator.SetFloat("SpeedY", (0f - num) * speed.z);
			float t = base.ellapsedTime / duration;
			character.transform.position = Vector3.Lerp(startPosition, desiredEndPosition, t);
		}
	}
}
